// 这是商品的路由模块
const Router = require('koa-router')

//导入商品模块
const Shop = require('../moudel/Shop')

const rt = new Router()


// 商品列表根据ID来
rt.get('/list/:pid', async (ctx)=>{
    let pid = ctx.params.pid

    let results = await Shop.FierShop(pid)

    ctx.body = results
})
// 商品搜索
rt.post('/search',async (ctx)=>{
    let id = ctx.request.body.id
    let name = ctx.request.body.sname
    let results = await Shop.Search(id,name)
    ctx.body = results
})
// 商品详情
rt.get('/detail/:sid',async (ctx)=>{
    let sid = ctx.params.sid
    let results = await Shop.DetailShop(sid)
    ctx.body = results
})

// 获取商品的尺码数据
rt.get('/size',async (ctx)=>{
    let results = await Shop.SizeList()
    ctx.body = results
})


// 将路由进行导出
module.exports = rt